import {takeEvery, put} from 'redux-saga/effects'
import { search_product, search_product_success } from '../actions/search'
import {API} from '../../config'
import axios from 'axios'


function* handleSearchProduct (action) {

	const {data} = yield axios.get(`${API}/products/search`, {
		params:action.payload
	})
	yield put(search_product_success({result: data}))
}

export default function* searchSaga () {
	yield takeEvery(search_product, handleSearchProduct)
}